import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { JVxeTypes, JVxeColumn } from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '编号',
    align: "center",
    sorter: true,
    dataIndex: 'workCenterCode'
  },
  {
    title: '名称',
    align: "center",
    sorter: true,
    dataIndex: 'workCenterName'
  },
  //  {
  //   title: '工作日历id',
  //   align:"center",
  //   dataIndex: 'workCalendarId'
  //  },
  {
    title: '工作日历',
    align: "center",
    dataIndex: 'workingCalendarName'
  },
  {
    title: '归属部门',
    align: "center",
    dataIndex: 'belongingDepartment'
  },
  //  {
  //   title: '归属部门id',
  //   align:"center",
  //   dataIndex: 'belongingDepartmentId'
  //  },
  {
    title: '联系人',
    align: "center",
    sorter: true,
    dataIndex: 'contact'
  },
  //  {
  //   title: '联系人id',
  //   align:"center",
  //   dataIndex: 'contactId'
  //  },
  {
    title: '联系电话',
    align: "center",
    sorter: true,
    dataIndex: 'contactPhone'
  },
  {
    title: '加工工艺',
    align: "center",
    dataIndex: 'processManagementName'
  },
  {
    title: '是否资源',
    align: "center",
    dataIndex: 'isProductionLine',
    customRender: ({ text }) => {
      return text == 0 ? '否' : text == 1 ? '是' : ''
    }
  },
  //  {
  //   title: '单据状态',
  //   align:"center",
  //   dataIndex: 'billStatus',
  //   customRender:({text})=>{
  //     return text==0?'开立':text==1?'审核':text==-1?'作废':''
  //   }
  //  },
  {
    title: '备注',
    align: "center",
    dataIndex: 'remark'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "编号",
    field: "workCenterCode",
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "名称",
    field: "workCenterName",
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "工作日历",
    field: "workingCalendarName",
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "联系人",
    field: "contact",
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "联系电话",
    field: "contactPhone",
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "日期",
    field: "workCenterDate",
    component: 'DatePicker',
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [

  // {
  //   label: '单据状态 0开立 1审核 -1作废',
  //   field: 'billStatus',
  //   component: 'Input',
  // },
  {
    label: '编号',
    field: 'workCenterCode',
    component: 'Input',
    rules: [
      {
        required: true,
        message: '编号必填',
        trigger: 'blur',
      },
    ]
  },
  {
    label: '名称',
    field: 'workCenterName',
    component: 'Input',
    rules: [
      {
        required: true,
        message: '名称必填',
        trigger: 'blur',
      },
    ]
  },
  {
    label: '加工工艺Id',
    field: 'processManagementId',
    component: 'Input',
    show: false
  },
  {
    label: '加工工艺',
    field: 'processManagementName',
    component: 'Input',
    slot: 'processNameSlot',
    // rules: [
    //   {
    //     required: true,
    //     message: '请输入加工工艺',
    //     trigger: 'blur',
    //   },
    // ]
  },
  {
    label: '工作日历id',
    field: 'workCalendarId',
    component: 'Input',
    show: false
  },
  {
    label: '工作日历',
    field: 'workingCalendarName',
    component: 'Input',
    slot: 'workingCalendarSlot',
    rules: [
      {
        required: true,
        message: '请输入工作日历',
        trigger: 'blur',
      },
    ]
  },
  {
    label: '归属部门',
    field: 'belongingDepartmentId',
    component: 'JSingleDepart',
    componentProps: ({ formActionType }) => {
      const { getProps } = formActionType;
      return {
        disabled: getProps.value.disabled,
        placeholder: '归属部门',
      }
    },
    rules: [
      {
        required: true,
        message: '归属部门必填',
        trigger: 'change',
      },
    ],
  },
  {
    label: '联系人',
    field: 'contactId',
    component: 'JSelectUser',
    componentProps: {
      labelKey: 'realname',
      rowKey: 'id',
      isRadioSelection: true,
      showButton: false,
    }
  },
  {
    label: '联系人id',
    field: 'contactId',
    component: 'Input',
    show: false
  },
  {
    label: '联系电话',
    field: 'contactPhone',
    component: 'Input',
    rules: rules.rule('phone', false),
  },

  {
    label: '是否资源',
    field: 'isProductionLine',
    component: 'Checkbox'
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
    colProps: {
      span: 24
    }
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];
//子表单数据
//子表表格配置
export const psWorkCenterItemColumns: JVxeColumn[] = [
  {
    title: '行号',
    key: 'rowNum',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
    readonly: true
  },
  {
    title: '工艺编号',
    key: 'processCode',
    type: JVxeTypes.slot,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
    slotName: 'processCodeSlot'
  },
  {
    title: '工艺名称',
    key: 'processName',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
    disabled: true
  },
  {
    title: '工艺说明',
    key: 'processIllustrate',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  }
]



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
